package com.xxx.springboot.listener;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * ApplicationRunner在srpingboot启动之后执行，和CommandLineRunner类似，区别在于后者的run()方法接受的参数是原始的，而前者封装了对象。
 * @author guwq
 * @since 2021/5/10
 */
@Component
public class MyApplicationRunner implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("===MyApplicationRunner==="+ Arrays.asList(args.getSourceArgs()));
        System.out.println("===getOptionNames========"+args.getOptionNames());
        System.out.println("===getOptionValues======="+args.getOptionValues("foo"));
        System.out.println("===getOptionValues========"+args.getOptionValues("user.name"));
    }
}
